scrolledwindow: Bug 766569 - Report child natural size unconditionally
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>
Sat, 4 Jun 2016 11:57:23 +0000 (20:57 +0900)
committerTristan Van Berkom <tristan.vanberkom@codethink.co.uk>
Mon, 6 Jun 2016 02:37:21 +0000 (11:37 +0900)
This patch causes the scrolled window default behavior to change in
such a way that the natural size request of the child is unconditionally
reported, which probably should have been the case since day 1.

This should not cause significant fallout since a scrolled window is
normally used to expand/fill, eating up remaining space for scrollable
content - it will however cause the scrolled window to compete for
additional space with siblings, proportionally to the size of the
scrolled window's content.

gtk/gtkscrolledwindow.c

index 1ef826b10827913c46987f8a15fdf94641fadd18..c6a9ca4bf2a913f3049cd34c93a2ae43d1169789 100644 (file)
@@ -1781,17 +1781,18 @@ gtk_scrolled_window_measure (GtkCssGadget   *gadget,
                                           &min_child_size,
                                           &nat_child_size);
 
+         natural_req.width += nat_child_size;
+
          if (priv->hscrollbar_policy == GTK_POLICY_NEVER)
            {
              minimum_req.width += min_child_size;
-             natural_req.width += nat_child_size;
            }
          else
            {
              if (priv->min_content_width >= 0)
                {
                  minimum_req.width += priv->min_content_width;
-                 natural_req.width += priv->min_content_width;
+                 natural_req.width  = MAX (priv->min_content_width, natural_req.width);
                  extra_width = -1;
                }
 
@@ -1822,17 +1823,18 @@ gtk_scrolled_window_measure (GtkCssGadget   *gadget,
                                            &min_child_size,
                                            &nat_child_size);
 
+         natural_req.height += nat_child_size;
+
          if (priv->vscrollbar_policy == GTK_POLICY_NEVER)
            {
              minimum_req.height += min_child_size;
-             natural_req.height += nat_child_size;
            }
          else
            {
              if (priv->min_content_height >= 0)
                {
                  minimum_req.height += priv->min_content_height;
-                 natural_req.height += priv->min_content_height;
+                 natural_req.height  = MAX (priv->min_content_height, natural_req.height);
                  extra_height = -1;
                }